package ex2.grammars;

import common.exceptions.ParseException;
import ex2.Token;
import fun.parser.Tree;
import ic.ast.Node;

/**
 * Created with IntelliJ IDEA.
 * User: Roi
 * Date: 11/22/13
 */
public interface IGrammar {
    /**
     * @return CFG definition
     */
    String getDefinition();

    /**
     * Parses tokens and creates parse tree
     * @param tokens source tokens
     * @return parse tree
     * @throws ParseException
     */
    Tree constructParseTree(Iterable<Token> tokens) throws ParseException;

    /**
     * Constructs abstract syntax tree according to given parse tree
     * @param parseTree source parse tree
     * @return ast
     * @throws Exception
     */
    Node constructAst(Tree parseTree) throws Exception;
}
